// pages/list/list.js
import {baseApi} from '../../../utils/util.js';
Page({
  data: {
    appointmentId:'',
    carNum:'',
    eta:'',
    etd:'',
    enterCode: {
      mode: 'scaleToFill',
      text: '进入码',
      code: '9527',
      src: 'https://bpic.588ku.com/element_origin_min_pic/01/37/31/24573c46572f507.jpg'
      
    }, 
    leaveCode: {
      mode: 'scaleToFill',
      text: '离开码',
      code: '9528',
      src: 'https://bpic.588ku.com/element_origin_min_pic/01/37/31/24573c46572f507.jpg'
    }
  },
  imageError: function(e) {
    console.log('image3发生error事件，携带值为', e.detail.errMsg)
  },
  onLoad(options) {
    const id = decodeURIComponent(options.id);
    console.log(id)
    this.data.appointmentId = id;
    var that = this;
    console.log('appointmentId:', id); // 输出: Name: 示例名称
    wx.request({
      url:  baseApi() + '/app/getVisitorAppointment?id='+id,
      method: 'GET',
      success(res){
        console.log(JSON.stringify(res));
        var data = res.data.data;
        console.log(JSON.stringify(data));
        that.setData({
          carNum:data.carNum,
          eta:data.eta,
          etd:data.etd,
          enterCode: {
            mode: 'scaleToFill',
            text: '进入码',
            code: data.enterCode,
            src: baseApi() + '/app/qrcode?code='+data.enterCode
          }, 
          leaveCode: {
            mode: 'scaleToFill',
            text: '离开码',
            code: data.leaveCode,
            src: baseApi() + '/app/qrcode?code='+data.leaveCode
          }
          });
      }
    })
  }
})